<script setup lang="ts">
import { onLaunch } from '@dcloudio/uni-app';
import { useStore } from 'vuex';
import appletsStore from './appletsStore';
import { userInfoWxData } from './pageTs/user';
import store from './store';
onLaunch(()=>{
	//本地缓存已存在登入信息 直接放入store中
	try{
		const vuexStore = useStore();
		const userByVuex=uni.getStorageSync('userInfoByVuex');
		if(userByVuex){
			vuexStore.commit('user/initInfo',userByVuex)
		}
		// 将本地缓存 放入非vuex的store中
		const user:userInfoWxData=uni.getStorageSync('userInfo');
		if(user){
			store.state.headimgurl=user.headimgurl;
			store.state.nickname=user.nickname;
		}	
		//微信小程序版 本地缓存获取数据
		const appletsUser=uni.getStorageSync('appleteUserInfo');
		if(appletsUser){
			appletsStore.state.headimgurl=appletsUser.headimgurl;
			appletsStore.state.nickname=appletsUser.nickname;
			appletsStore.state.pkId=appletsUser.pkId;
		}	
	}catch(e){
		console.log('提取用户信息失败');
	}
})
</script>

<style>
	/*每个页面公共css */
</style>
